<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Restaurant_account_DAO {

    public static $TABLENAME = 'restaurant_account';

    public static $_db;

    public static function query($str)
    {
        if(self::$_db === null) {
            self::$_db = \GatewayWorker\Lib\Db::instance('main');
            return self::$_db->query($str);
        } else {
            return self::$_db->query($str);
        }
    }



    public static function getList() {
        $where = "";
        $list = self::query('select * from '.static::$TABLENAME);
        $results = array();

        foreach($list as $record){
            $results[] = new Restaurant_account($record);
        }
        return $results;
    }


    public static function insert($record){
        try {
            $sql = 'insert into '.static::$TABLENAME .' values '.$record->toInsertCSV();
            self::query($sql);
        } catch(MyException $e){
            throw $e;
        }
    }
}

